package com.e.dianshang.controller.Api;

import com.e.dianshang.service.AdviceService;
import com.e.dianshang.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@CrossOrigin
@Api(value = "用户建议模块",tags = "建议api")
public class AdviceApi {

    @Resource
    AdviceService adviceService;

    JsonResult jsonResult;

    @RequestMapping("insertAdvice")
    @ApiOperation(value = "添加用户意见",httpMethod = "POST")
    @ApiImplicitParam(name = "map",value = "意见表的所有信息",dataType = "string")
    public Map insert(@RequestBody Map map){
        jsonResult=new JsonResult();
        Integer integer = adviceService.insertAdvice(map);
        if (integer>0){
            jsonResult.setData("1");
            jsonResult.setMsg("添加成功");
        }else {
            jsonResult.setCode("0");
        }
        return jsonResult.getValues();
    }
}